﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Ninject;
using System.Web.Http;
using System.Web.Optimization;
using Moq;
using WebDauGia.Domain.Abstract;
using WebDauGia.Domain.Models;
using WebDauGia.Domain.Concrete;
using WebDauGia.Infrastructure.Abstract;
using WebDauGia.Infrastructure.Concrete;
using System.Configuration;


namespace WebDauGia.Infrastructure
{
    public class NinjectControllerFactory:DefaultControllerFactory
    {
        private IKernel ninjectKernel;
        public NinjectControllerFactory(){
            ninjectKernel = new StandardKernel();
            AddBindings();
        }
        protected override IController GetControllerInstance(RequestContext
            requestContext, Type controllerType){
            return controllerType == null ? null: (IController)ninjectKernel.Get(controllerType);
        }

        private void AddBindings(){
            //put bindings here
            ninjectKernel.Bind<WebRepository>().To<EFRepository>();
           /* EmailSettings emailSettings = new EmailSettings
            {
                WriteAsFile = bool.Parse(ConfigurationManager.AppSettings["Email.WriteAsFile"] ?? "false")
            };
            ninjectKernel.Bind<IOrderProcessor>
                .To<EmailOrderProcessor>()
                .WithConstructorArgument("settings", emailSettings);*/
            ninjectKernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
            
        }
      
    }
}
